package com.xingdian.xingdianhulianweb.service.impl;

import com.github.pagehelper.PageHelper;
import com.xingdian.xingdianhulianweb.common.QueryObject;
import com.xingdian.xingdianhulianweb.common.ServerResponse;
import com.xingdian.xingdianhulianweb.mapper.CityMapper;
import com.xingdian.xingdianhulianweb.mapper.IpInfoMapper;
import com.xingdian.xingdianhulianweb.mapper.NewsMapper;
import com.xingdian.xingdianhulianweb.mapper.ShopAddressMapper;
import com.xingdian.xingdianhulianweb.service.IpInfoService;
import com.xingdian.xingdianhulianweb.vo.IpInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/* *
 * @Author H2SO4
 * @ClassName: IpInfoService
 * @Description TODO
 * @Date 2019/11/26--15:18
 * */
@Service
public class IpInfoServiceImpl implements IpInfoService {

    @Autowired
    IpInfoMapper ipInfoMapper;

    @Autowired
    NewsMapper newsMapper;

    @Autowired
    CityMapper cityMapper;

    @Autowired
    ShopAddressMapper shopAddressMapper;

    @Override
    public ServerResponse findIpInfo() {
        List<IpInfo> list1 = ipInfoMapper.findIpInfo1();
        List<IpInfo> list2 = ipInfoMapper.findIpInfo2();
        List<IpInfo> list3 = ipInfoMapper.findIpInfo3();
        List<IpInfo> list4 = ipInfoMapper.findIpInfo4();
        List<IpInfo> list5 = ipInfoMapper.findIpInfo5();
        List<IpInfo> list6 = ipInfoMapper.findIpInfo6();
        List<IpInfo> list7 = ipInfoMapper.findIpInfo7();
        List<IpInfo> list8 = ipInfoMapper.findIpInfo8();
        List<IpInfo> list9 = ipInfoMapper.findIpInfo9();
        Map<String,Object> map =  new HashMap<>();
        map.put("list1",list1);
        map.put("list2",list2);
        map.put("list3",list3);
        map.put("list4",list4);
        map.put("list5",list5);
        map.put("list6",list6);
        map.put("list7",list7);
        map.put("list8",list8);
        map.put("list9",list9);
        return ServerResponse.createBySuccess(map);
    }

    @Override
    public ServerResponse findIpInfos() {
        List<IpInfo> list1 = ipInfoMapper.findIpInfos1();
        List<IpInfo> list2 = ipInfoMapper.findIpInfos2();
        List<IpInfo> list3 = ipInfoMapper.findIpInfos3();
        List<IpInfo> list4 = ipInfoMapper.findIpInfos4();
        List<IpInfo> list5 = ipInfoMapper.findIpInfos5();
        List<IpInfo> list6 = ipInfoMapper.findIpInfos6();
        List<IpInfo> list7 = ipInfoMapper.findIpInfos7();
        List<IpInfo> list8 = ipInfoMapper.findIpInfos8();
        List<IpInfo> list9 = ipInfoMapper.findIpInfos9();
        List<IpInfo> list10 = ipInfoMapper.findIpInfos10();
        List<IpInfo> list11 = ipInfoMapper.findIpInfos11();
        List<IpInfo> list12 = ipInfoMapper.findIpInfos12();
        List<IpInfo> list13 = ipInfoMapper.findIpInfos13();


        Map<String,Object> map =  new HashMap<>();
        map.put("list1",list1);
        map.put("list2",list2);
        map.put("list3",list3);
        map.put("list4",list4);
        map.put("list5",list5);
        map.put("list6",list6);
        map.put("list7",list7);
        map.put("list8",list8);
        map.put("list9",list9);
        map.put("list10",list10);
        map.put("list12",list12);
        map.put("list13",list13);
        map.put("list11",list11);
        return ServerResponse.createBySuccess(map);
    }

    @Override
    public Map<String,Object> jdlist(QueryObject queryObject) {
        Map<String,Object> map = new HashMap<>();
        PageHelper.startPage(queryObject.getCurrentPage(), queryObject.getPageSize());
        List<Map<String,Object>> list = newsMapper.findAll(queryObject);
        int total = newsMapper.countNews();
        map.put("rows",list);
        map.put("total",total);
        return map;
    }

    //集团资讯
    @Override
    public Map<String, Object> jtlist(QueryObject queryObject) {
        Map<String,Object> map = new HashMap<>();
        PageHelper.startPage(queryObject.getCurrentPage(), queryObject.getPageSize());
        List<Map<String,Object>> list = newsMapper.findAlljt(queryObject);
        int total = newsMapper.countjtNews();
        map.put("rows",list);
        map.put("total",total);
        return map;
    }

    //媒体报道
    @Override
    public Map<String, Object> mtlist(QueryObject queryObject) {
        Map<String,Object> map = new HashMap<>();
        PageHelper.startPage(queryObject.getCurrentPage(), queryObject.getPageSize());
        List<Map<String,Object>> list = newsMapper.findAllmt(queryObject);
        int total = newsMapper.countmtNews();
        map.put("rows",list);
        map.put("total",total);
        return map;
    }

    //省份下拉列表
    @Override
    public List<Map<String,Object>> getAreaList() {
        List<Map<String,Object>> list = cityMapper.findAll();
        return list;
    }

    //查询店铺列表
    @Override
    public List<Map<String, Object>> getStoreList(Integer province,String key) {
        List<Map<String,Object>> list = shopAddressMapper.findAll(province,key);
        return list;
    }
}
